﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Lifang.Common;

namespace Lifang.API.Controllers
{
    [Produces("application/json")]
    [Route("api/Base")]
    public class BaseController : Controller
    {
        #region 分页
        private DataPage _pager;
        /// <summary>翻页DataPage</summary>
        public DataPage Pager
        {
            get
            {
                _pager = new DataPage { PageSize = 20, PageIndex = 1, PageCount = 1, RowCount = 0 };
                if (Request != null)
                {
                    //if (Request[DataPage.PageIndexField] != null)
                    //    _pager.PageIndex = Request[DataPage.PageIndexField] == null ? 0 : int.Parse(Request[DataPage.PageIndexField]);
                    //if (Request[DataPage.PageSizeField] != null)
                    //    _pager.PageSize = Request[DataPage.PageSizeField] == null ? 0 : int.Parse(Request[DataPage.PageSizeField]);
                }
                return _pager;
            }
            set
            {
                _pager = value;
                ViewData["DataPage"] = _pager;
            }
        }
        #endregion


        #region 常用属性

        public LoginUserModel LoginUserModel
        {
            get
            {

                var loginUserModel = new LoginUserModel() { UserName = "游客", UserNo = "0000" };
                return loginUserModel;               
            }
        }

        public string BasePath
        {
            get
            {
                string basePath = Url.Content("~");
                return basePath;
            }
        }       
        #endregion
    }
}